<template>
	<view class="login">
		<!-- 顶部结构start -->
		<view class="nav">
			<view class="nav-left">
				<view class="nav-icon">
					<image src="../../static/images/home_active.png" mode="widthFix" class="img"></image>
				</view>
				<view class="nav-txet">
					Luckin Coffee
				</view>
			</view>
			<view class="nav-right">
				先逛一逛
			</view>
		</view>
		<!-- 顶部结构end -->
		<!-- 文本结构 start -->
		<view class="section">
			
		<view class="section-name">
			找回密码！
		</view>
		<view class="section-enname">
			please
		</view>
		</view>
		<!-- 文本结构 start -->
		<!-- 登录结构 start -->
		<view class="nav-login">
			<u-form :model="form" ref="uForms">
				<u-form-item label="手机号" prop="number">
					<u-input v-model="form.number" type="text" placeholder="请输入手机号" />
				</u-form-item>
				<u-form-item label="密码" prop="password">
					<u-input v-model="form.password" type="password" placeholder="请输入密码" />
				</u-form-item>
			</u-form>
			<view class="goTo" @click="goTo">
				已有账号，立即登录
			</view>
		</view>
		<!-- 登录结构 end-->
		<button @click="submit" class="btn_1 common">提交</button>
		<button @click="back" class="btn_2 common">返回</button>
	

	</view>
</template>

<script>
	import request from "../../request/request.js"
	export default {
		data() {
			return {
				show: false,
				form: {
					number: '',
					password: ""
				},
				rules: {
					number: [{
						required: true,
						pattern: /^1[3-9]\d{9}$/,
						message: '请输入正确手机号',
						// trigger: ['blur', 'change']
					}],
					password: [{
						required: true,
						pattern: /^[A-Za-z]\w{5,15}$/,
						message: '请输入正确密码',
						// trigger: ['blur', 'change']
					}]
				}
			}
		},
		methods: {
			submit() {
				this.$refs.uForms.validate(valid => {
					if (valid) {
						this.getNewPassword()
					} else {
						console.log('验证失败');
					}
				});
			},
			getNewPassword(){
				console.log(this.form.password,this.form.number)
				request({
					
					url: "/retrievePassword",
					method: "POST",
					data: {
						phone:this.form.number,
						password:this.form.password
					},
					success:(res)=>{
						console.log(res)
						if(res.code==200){
							uni.showToast({
								title:res.data.msg,
								icon:"none",
								mask:true,
								duration:1000
							})
							// uni.navigateTo({
							// 	url: "../sigin/sigin"
							// })
						}
						
						
					}
				})
			},
			
			goTo(){
				
				uni.navigateTo({
					url:"../login/login"
				})
			},
			back(){
				uni.navigateBack({
					delta:1
				})
			}


		},
		onReady() {
			this.$refs.uForms.setRules(this.rules);
		}
	}
</script>

<style lang="less" scoped>
	.login{
		.nav{
			height: 120rpx;
			padding: 0 30rpx;
			padding-bottom: 20rpx;
			background-color: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.nav-left{
				flex: 7.5;
				display: flex;
				align-items: center;
				.nav-icon{
					width: 75rpx;
					height: 75rpx;
					.img{
						width: 100%;
					}
				}
				.nav-txet{
					color: #999;
					font-size: 38rpx;
					font-weight: bold;
					margin-left: 30rpx;
				}
			}
			.nav-right{
				color: #0c34ba ;
				font-size: 34rpx;
				font-weight: bold;
				flex: 2.5;
				
			}
		}
		.section{
			margin: 0 30rpx;
			margin-top: 180rpx;
			.section-name{
				font-size: 80rpx;
				font-weight: bold;
			}
			.section-enname{
				margin: 50rpx 0;
				margin-bottom: 80rpx;
				font-size: 40rpx;
			}
		}
		.nav-login{
			.goTo{
				margin:50rpx 30rpx;
				float: right;
			}
		}
		.common{
			height: 100rpx;
			font-size: 34rpx;
			border-radius: 80rpx;
			margin: 80rpx 30rpx ;
			line-height: 100rpx;
			text-align: center;
		}
		.btn_1{
			color: #fff;
			background-color:#0c34ba ;
			margin-top: 150rpx;
		}
		.btn_2{
			border: 2rpx solid #ccc;
		}
		::v-deep .u-border-bottom{
			border-bottom: 2rpx solid #ccc;
			margin: 0 50rpx;
		}
		::v-deep .u-form-item--left__content__label{
			width: 100rpx;
		}
		::v-deep .u-form-item--right__content__slot {
			margin-left: 30rpx;
		}
		::v-deep .u-form-item__message{
			display: none;
		}
	}
</style>
